public class BJL {
	public static void main(String[] args) {

		
		for(int x=0;x<1000;x++){
		
		int playerWin = 0;
		int playerLoss = 0;
		int bankWin = 0;
		int bankLoss = 0;
		int tieCount = 0;
		int long7Count = 0;
		int long7bet = 0;
		int long7winCount = 0;
		boolean pFlag = false;

		int times = 100000;
		
		double usingRCount=-1111118;
		int itimes = 1;

		for (int j = 0; j < times; j++) {
			Shoe shoe = new Shoe(8);
			for (int i = 0; i < itimes; i++) {
				boolean long7Flag = false;
//				long7bet++;
				if (shoe.getrCount() >= usingRCount) {
					long7bet++;
					long7Flag = true;
				}
				P p1 = shoe.dealRandomCard();
				P p2 = shoe.dealRandomCard();
				int firstCount = 10;
				int firstCountDeal = 10;
				int count = 10;
				int countDeal = 10;
				if (p1.getNum() < 10) {
					count = count + p1.getNum();
					firstCount = firstCount + p1.getNum();
				}
				if (p2.getNum() < 10) {
					count = count + p2.getNum();
					firstCount = firstCount + p2.getNum();
				}

				P p4 = shoe.dealRandomCard();
				P p5 = shoe.dealRandomCard();

				P p3 = null;
				P p6 = null;

				if (p4.getNum() < 10) {
					countDeal = countDeal + p4.getNum();
					firstCountDeal = firstCountDeal + p4.getNum();
				}
				if (p5.getNum() < 10) {
					countDeal = countDeal + p5.getNum();
					firstCountDeal = firstCountDeal + p5.getNum();
				}

				if ((count % 10 >= 8) || (countDeal % 10 >= 8)) {

				} else {
					if (count % 10 <= 5) {
						p3 = shoe.dealRandomCard();

						if (p3.getNum() < 10) {
							count = count + p3.getNum();
						}

						if (countDeal % 10 <= 2) {
							p6 = shoe.dealRandomCard();
						} else if (countDeal % 10 == 3) {
							if (p3.getNum() != 8) {
								p6 = shoe.dealRandomCard();
							}
						} else if (countDeal % 10 == 4) {
							if (p3.getNum() != 1 && p3.getNum() != 8 && p3.getNum() != 9 && p3.getNum() != 10 && p3.getNum() != 11 && p3.getNum() != 12 && p3.getNum() != 13) {
								p6 = shoe.dealRandomCard();
							}
						} else if (countDeal % 10 == 5) {
							if (p3.getNum() == 4 || p3.getNum() == 5 || p3.getNum() == 6 || p3.getNum() == 7) {
								p6 = shoe.dealRandomCard();
							}
						} else if (countDeal % 10 == 6) {
							if (p3.getNum() == 6 || p3.getNum() == 7) {
								p6 = shoe.dealRandomCard();
							}
						} else if (countDeal % 10 == 7) {

						}
						if (p6 != null && p6.getNum() < 10) {
							countDeal = countDeal + p6.getNum();
						}

					} else if (count % 10 == 6 || count % 10 == 7) {

						if (countDeal % 10 <= 5) {
							p6 = shoe.dealRandomCard();

							if (p6.getNum() < 10) {
								countDeal = countDeal + p6.getNum();
							}
						}

					} else {

					}

				}

				if (long7Flag) {
					if (count % 10 > countDeal % 10) {
						playerWin++;
						bankLoss++;
					} else if (count % 10 == countDeal % 10) {
						tieCount++;
					} else {
						playerLoss++;
//						if (countDeal % 10 == 7 && p6 != null) {
//							long7winCount++;
//							tieCount++;
//						} else {
							bankWin++;
//						}
					}
				}
			}

		}

		double l = (bankWin * 0.95 - bankLoss) / long7bet+0.0125;
		double l1 = (playerWin * 1.0 - playerLoss) / long7bet;
		double l2 = (playerWin * 1.0) / long7bet;
		double l3 = (bankWin * 1.0) / long7bet;
		
		
//		System.out.println("usingRCount       :  " + usingRCount);
//		System.out.println("Banker win:          " + (bankWin * 1.0));
//		System.out.println("Banker loss:         " + (bankLoss * 1.0));
//		System.out.println("Banker total win:    " + (bankWin * 1.0 - bankLoss));
//		System.out.println("Total count    :     " + long7bet);
//		
//		System.out.println("Player win precent:  " + l2);
//		System.out.println("Banker win precent:  " + l3);
//		System.out.println("Player EV:           " + l1);
		System.out.println( l);
//
//		System.out.println("Player win:          " + playerWin);
//		System.out.println("Banker win:          " + bankWin);
//		System.out.println("Tie:                 " + tieCount);
//		System.out.println("Long7  win precent:    " + long7winCount * 1.0 / long7bet);
//
//		System.out.println("Total win:           " + (long7winCount * 41 - long7bet) * 1.0);
//		System.out.println("EV=                  " + (long7winCount * 41 - long7bet) * 1.0 / long7bet);
//		System.out.println("Frequence=           " + long7bet * 1.0 / (times * itimes));

		}
	}
}
